import Mock from 'mockjs'

export default {
  getMenu: config =>{
    const {username,password} = JSON.parse(config.body)
    if(username === 'admin' && password === 'admin'){
      return {
        code:200,
        message:'请求成功',
        data:{
          menuList:[
            {
              path:'/home',
              name:'Home',
              meta:{
                title:'首页'
              },
              icon:'house',
              url:'Home'
            },
            {
              path:'/user',
              name:'User',
              meta:{
                title:'用户管理'
              },
              icon:'user',
              url:'User'
            },
            {
              path: '/mall',
              name: 'Mall',
              meta: {
                title: '商品管理'
              },
              icon: 'video-play',
              url: 'Mall'
            },
            {
              path: '/other',
              name: 'Other',
              meta: {
                title: '其他'
              },
              icon: 'location',
              children: [
                {
                  path: '/page1',
                  name: 'Page1',
                  meta: {
                    title: '页面1'
                  },
                  icon: 'setting',
                  url: 'Page1'
                },
                {
                  path: '/page2',
                  name: 'Page2',
                  meta: {
                    title: '页面2'
                  },
                  icon: 'setting',
                  url: 'Page2'
                },
              ]
            }
          ],
          token: Mock.Random.guid(),
          message:'登录成功'
        }
      }
    }
    else if(username === 'zs' && password === '123456'){
      return {
        code:200,
        message:'请求成功',
        data:{
          menuList:[
            {
              path:'/home',
              name:'Home',
              meta:{
                title:'首页'
              },
              icon:'house',
              url:'Home'
            },
            {
              path:'/user',
              name:'User',
              meta:{
                title:'用户管理'
              },
              icon:'user',
              url:'User'
            }
          ],
          token: Mock.Random.guid(),
          message:'登录成功'
        }
      }
    }
    else{
      return {
        code:500,
        message:'用户名或密码错误',
      }
    }
  }
}
